var api = require('../../util/api.js');
Page({

  data: {

  },
  onLoad: function (options) {
    var _this = this;
    if(api.isBlank(options.id)){
      _this.setData({
        isEdit: false,
        item: {
          judgeId : api.getSysUser().userId,
          judgeName : api.getSysUser().userName,
          examineId : _this.options.examineId,
          userId : _this.options.userId,
          userName : _this.options.userName
        }
      })
    }else{
      api.get(`${api.url.zjjd.jdhp}/${options.id}`).then(res => {
          _this.setData({
            isEdit: true,
            item: res.data
          });
      })
    }
  },
  submit(e){
    var _this = this;
    var params = e.detail.value;
    if(_this.data.isEdit){
      api.put(api.url.zjjd.jdhp, params).then(res => {
        api.back("修改成功", "success");
      })
    }else{
      api.post(api.url.zjjd.jdhp, params).then(res => {
        api.back("新增成功", "success");
      })
    }
    
  }
})